<?php
$this->layout()->setLayout('restrict_actions');
echo $this->title;

$banners = $this->content;
echo $this->flashMessages();
?>
<?php if (count($banners)): ?>
    <table>
        <caption>Lista de banners cadastrados no sistema</caption>
        <thead>
            <tr>
                <th class="header">Imagem</th>
                <th class="header">Cadastrado por</th>
                <th class="header">Título</th>
                <th class="header">Resolução</th>
                <th class="header">Link</th>
                <th class="header">Alterar</th>
                <th class="header">Status</th>
                <th class="header">Excluir</th>
            </tr>

        </thead>

        <tbody>
            <?php
            foreach ($banners as $banner):
                ?>
                <tr>
                    <td>
                        <a title="teste" rel="lightbox[roadtrip]" href="<?php echo $banner->getImagePath(); ?>">
                            <img width="50" height="50" alt="teste" src="<?php echo $banner->getImagePath(); ?>">
                        </a>
                    </td>

                    <td><?php echo $banner->getUsuario()->getNomeUsuario(); ?></td>

                    <td><?php echo $banner->getTitulo(); ?></td>

                    <td><?php echo $banner->getResolucao(); ?></td>

                    <td>
                        <a target="_blank" title="<?php echo $banner->getTitulo(); ?>" href="<?php echo $banner->getLocalizacao(); ?>">
                            <?php echo $banner->getLocalizacao(); ?>                        
                        </a> 
                    </td>

                    <td>
                        <a title="Alterar banner <?php echo $banner->getTitulo(); ?>" href="<?php echo BASE_URL . 'restrita/update-banner/id/' . (int) $banner->getIdBanner(); ?>">
                            <img src="<?php echo BASE_IMG . 'fatias/edit.png'; ?>">
                        </a>
                    </td>

                    <td>
                        <a title="<?php echo ($banner->getStatus()) ? 'Desativar' : 'Ativar'; ?> banner <?php echo $banner->getTitulo(); ?>" href="<?php echo ($banner->getStatus()) ? BASE_URL . "restrita/alterar-status-banner/status/desativarBanner/id/" . (int) $banner->getIdBanner() : BASE_URL . 'restrita/alterar-status-banner/status/ativarBanner/id/' . (int) $banner->getIdBanner(); ?> ">
                            <img src="<?php echo ($banner->getStatus()) ? BASE_IMG . 'fatias/open.png' : BASE_IMG . 'fatias/close.png'; ?>">
                        </a>
                    </td>

                    <td>
                        <a onclick="return excluir('Banner <?php echo $banner->getTitulo(); ?>')" title="excluir <?php echo $banner->getTitulo(); ?>" href="<?php echo BASE_URL . 'restrita/delete-banner/id/' . (int) $banner->getIdBanner(); ?>">
                            <img src="<?php echo BASE_IMG ?>fatias/delete.png">
                        </a>
                    </td>

                </tr>
            <?php endforeach; ?>
        </tbody>

        <tfoot>
            <tr>
                <th>Imagem</th>
                <th>Cadastrado por</th>
                <th>Título</th>
                <th>resolução</th>
                <th>Link</th>
                <th>Alterar</th>
                <th>Status</th>
                <th>Excluir</th>
            </tr>
        </tfoot>
    </table>
    <?php
else:
    echo 'Nenhum banner cadastrado';
endif;
?>

